//
//  SHChangeFooter.m
//  JiFengDaRen
//
//  Created by SH_iOS on 2017/10/17.
//  Copyright © 2017年 SH_iOS. All rights reserved.
//

#import "SHChangeFooter.h"
@interface SHChangeFooter()
@property(nonatomic,strong)SHButton *changeBtn;

@end
@implementation SHChangeFooter

-  (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.backgroundColor = KBASEBGCOLOR;
        
        [self.changeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.mas_equalTo(self);
            make.centerY.mas_equalTo(self);
            make.width.mas_equalTo(__I6Width(326));
            make.height.mas_equalTo(__I6Height(42));

            
        }];
    }
    
    
    return self;
}

- (SHButton *)changeBtn{
    
    if(!_changeBtn){
        _changeBtn = [SHButton buttonWithType:UIButtonTypeCustom title:@"" font:15 titleColor:[UIColor whiteColor] textAlignment:0 forState:UIControlStateNormal];
        
        _changeBtn.backgroundColor = KREDCOLOR;
        _changeBtn.userInteractionEnabled = NO;
        _changeBtn.layer.cornerRadius = __I6Height(5);
        _changeBtn.layer.masksToBounds = YES;
        [_changeBtn addTarget:self action:@selector(changeCardBtnAction:) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:_changeBtn];
        
    }
    return _changeBtn;
    

}
- (void)changeCardBtnAction:(SHButton *)sender{
    
    if ([_delegate respondsToSelector:@selector(changeFooter:changeCardBtn:)]) {
        [_delegate changeFooter:self changeCardBtn:sender];

    }
    
    
}
- (void)setButtonTitle:(NSString *)buttonTitle{
    
    _buttonTitle = buttonTitle;
    [_changeBtn setTitle:buttonTitle forState:UIControlStateNormal];
}

- (void)setIsClickedBtn:(BOOL)isClickedBtn{
    
    if (isClickedBtn) {
        _changeBtn.backgroundColor = KREDCOLOR;
        _changeBtn.userInteractionEnabled = YES;
        
    }else{
        _changeBtn.backgroundColor = [UIColor colorWithWhite:208.f/255 alpha:1];
        _changeBtn.userInteractionEnabled = NO;

    }
    
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
